[Android SDK] Text-To-Speech addSpeech not working properly

Posted by arcoraven on Stack Overflow See other posts from Stack Overflow or by arcoraven
Published on 2010-04-13T20:29:47Z Indexed on 2010/04/13 20:33 UTC
Read the original article Hit count: 289

Filed under:
|
|

Hi, I'm trying to get my Android app to play a .wav file recording of the word "Spinach Salad" whenever it sees that phrase being spoken by TTS. Here's the relevant code:

spinach_salad.wav is located in /res/raw

prodName = "Spinach Salad"
mTts.addSpeech(prodName, "com.example.textextractor", R.raw.spinach_salad);

...and later in the code:

mTts.speak("blah blah blah " + prodName, TextToSpeech.QUEUE_ADD, null);

I've also tried:

mTts.speak("blah blah blah Spinach Salad", TextToSpeech.QUEUE_ADD, null);

and

mTts.speak("blah blah blah", TextToSpeech.QUEUE_ADD, null);
mTts.speak(productName_str, TextToSpeech.QUEUE_ADD, null);

In both cases, I'm just hearing the TTS synthesized audio, rather than my custom .wav file. (On a related note, the last chunk of code sometimes speaks out of order, saying the second line before the first).

© Stack Overflow or respective owner

Related posts about android

Related posts about TTS